<?php
/**
 * PHP Framework emission web service
 *
 * @author Andrew <andrew@vitche.com>
 * @author Frozen Rain <frozenrain@mail.ru>
 **/

$root = '.';

// Includes
$file = $root . '/Framework.Core/Reflection/Emit/NamingConventionMapper.php';
if (is_file($file)) {
    require_once($file);
}

$file = $root . '/Framework.Core/Reflection/Emit/ClassRegistrar.php';
if (is_file($file)) {
    require_once($file);
}

ClassRegistrar::attach('Framework.Core', '');
ClassRegistrar::attach('Framework.AI', '');
ClassRegistrar::attach('Framework.DomainModel', '');
ClassRegistrar::attach('Framework.Integration', '');
ClassRegistrar::attach('Framework.Icq', '');
ClassRegistrar::attach('Framework.InternetSearch', '');
ClassRegistrar::attach('Framework.CommerceCore', '');
ClassRegistrar::attach('Framework.QualityAssurance', '');
ClassRegistrar::attach('Framework.Seo', '');
ClassRegistrar::attach('Framework.SiteMap', '');
ClassRegistrar::attach('Framework.UI', '');
ClassRegistrar::attach('Framework.WordPress', '');

class EmitWebService extends HTTPWebService {

    protected function onMethodCall($class, $method, $arParameters) {

        if ('EmitWebService' == $class) {

            if ('get' == $method) {

                if (!isset($arParameters['namespace'])) {

                    $arParameters['namespace'] = 'Framework.Core.Reflection.Emit';
                    $arParameters['class'] = 'CodeProxy';
                }

                if (!isset($arParameters['class'])) {
                    $arParameters['class'] = '';
                }

                return ClassRegistrar::get($arParameters['namespace'], $arParameters['class']);
            } else if ('list' == $method) {

                return serialize(ClassRegistrar::getList());
            }
        }
    }
}

$EmitWebService = new EmitWebService();
?>